package design2.prototype.example.caching;

import design2.prototype.example.caching.cache.BundledShapeCache;
import design2.prototype.example.shapes.Shape;

public class Demo {
	public static void main(String[] args) {
		BundledShapeCache cache=new BundledShapeCache();

		Shape shape1=cache.getShape("Big green circle");
		Shape shape2=cache.getShape("blue rectangle");
		Shape shape3=cache.getShape("blue rectangle");

		if(shape1!=shape2&&!shape1.equals(shape2)){
			System.out.println("大绿圈！=中蓝色矩形（耶！）");
		}else{
			System.out.println("大绿色圆圈==中蓝色矩形（booo！）");
		}
		System.out.println("----------------------------------");
		if(shape2!=shape3){
			System.out.println("中蓝色矩形是两个不同的对象（耶！）");
			if(shape2.equals(shape3)){
				System.out.println("它们是一样的（耶！）");
			}else{
				System.out.println("但它们并不完全相同（嘘！）");
			}
		}else{
			System.out.println("矩形对象是相同的（booo！）");
		}
	}
}
